﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class PopupWin : MonoBehaviour
{

	public Text tClear;
	public Button bNext, bMenu, bSelectLevel;

	void OnEnable ()
	{
		if (GameManager.currentLevel == GameManager.dataSave.levelMax.GetValue ()) {
			GameManager.dataSave.levelMax += new SafeInt (1);
			GameManager.SaveData ();
		}
	}

	public void Next ()
	{
		AudioManager.instance.PlaySound (AudioClipType.SE_Enter);
		GameManager.currentLevel++;
		GameplayControl.instance.StartNewGame ();
		AudioManager.instance.PlayMusic (AudioClipType.BGM_InGame);
		gameObject.SetActive (false);
	}

	public void Menu ()
	{
		AudioManager.instance.PlaySound (AudioClipType.SE_Enter);
		GameManager.gameState = GameState.MENU;
		WindowManager.OpenWindow (WindowName.GW_MENU);
		gameObject.SetActive (false);
	}

	public void SelectLevel ()
	{
		AudioManager.instance.PlaySound (AudioClipType.SE_Enter);
		GameManager.gameState = GameState.SELECT_LEVEL;
		WindowManager.OpenWindow (WindowName.GW_SELECT_LEVEL);
		GW_SELECT_LEVEL.instance.levelPage = GameManager.dataSave.levelMax.GetValue () / 16;
		gameObject.SetActive (false);
	}

}
